package com.whq.thrift.api.web.admin.db.config;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

public interface ErrorCodeMapper {
	@Select("select * from t_error_code where error_code=#{errorCode}")
	@Results(value = {
			@Result(property = "errorCode", column = "error_code"), 
			@Result(property = "errorMsg", column = "error_msg"),
			@Result(property = "businessType", column = "business_type"), 
			@Result(property = "moduleName", column = "module_name"),
			@Result(property = "developer", column = "developer"),
			@Result(property = "comment", column = "comment"),
			@Result(property = "createTime", column = "create_time"), 
			@Result(property = "updateTime", column = "update_time") })
	public ErrorCode getSelectRecordByKey(@Param("errorCode") String errorCode);

	@Select("select * from t_error_code")
	@Results(value = {
			@Result(property = "errorCode", column = "error_code"), 
			@Result(property = "errorMsg", column = "error_msg"),
			@Result(property = "businessType", column = "business_type"), 
			@Result(property = "moduleName", column = "module_name"),
			@Result(property = "developer", column = "developer"),
			@Result(property = "comment", column = "comment"),
			@Result(property = "createTime", column = "create_time"), 
			@Result(property = "updateTime", column = "update_time") })
	public List<ErrorCode> getSelectRecordAll();
	
	@SelectProvider(type = ErrorCodeProvider.class, method = "getSelectRecrodSql")
	@Results(value = { 
			@Result(property = "errorCode", column = "error_code"),
			@Result(property = "errorMsg", column = "error_msg"),
			@Result(property = "businessType", column = "business_type"), 
			@Result(property = "moduleName", column = "module_name"),
			@Result(property = "developer", column = "developer"), 
			@Result(property = "comment", column = "comment"),
			@Result(property = "createTime", column = "create_time"), 
			@Result(property = "updateTime", column = "update_time") })
	public List<ErrorCode> getSelectRecordByMap(Map<String, Object> whereParams);

	@Insert("INSERT INTO t_error_code (error_code, error_msg,business_type, module_name, developer," +
			"comment, create_time,update_time) VALUES(#{errorCode},#{errorMsg},#{businessType}," +
			"#{moduleName},#{developer},#{comment},#{createTime},#{updateTime})")
	public void addRecord(ErrorCode record);

	@SelectProvider(type = ErrorCodeProvider.class, method = "getSelectCountSql")
	public int getSelectCountByKey(Map<String, Object> whereParams);

	@UpdateProvider(type = ErrorCodeProvider.class, method = "getUpdateSql")
	public void updRecord(ErrorCode record);

	@Delete("delete from t_error_code where error_code=#{errorCode}")
	public void delRecord(@Param("errorCode") String errorCode);
}
